cmake_minimum_required(VERSION 3.10)

# Setup the project.
# Its name is defined to be the controller directory name.
# CMAKE_SOURCE_DIR:CMakeLists.txt所在的路径 从中读取到所在的文件夹的名字
get_filename_component(PROJECT ${CMAKE_SOURCE_DIR} NAME)
message(STATUS "================================================")
message(STATUS "cmake_source_dir: ${CMAKE_SOURCE_DIR}")
message(STATUS "PROJECT: ${PROJECT}")
message(STATUS "================================================")
# set(PROJECT "my_controller")
project(${PROJECT})

set( CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set( CMAKE_CXX_STANDARD 14)
set( CMAKE_C_STANDARD 11)
set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) 
set( LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/lib) 

# # Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message("Setting build type to 'Debug' as none was specified.")
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for test_footStest_footPlacementtepPlan-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

# Get C or C++ sources in the current directory (only).
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>添加源文件SRC<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/USP SOURCES)
message(STATUS "mainCmake:${SOURCES}")
aux_source_directory(${PROJECT_SOURCE_DIR}/USP/usb_com SOURCES)
message(STATUS "mainCmake:${SOURCES}")
aux_source_directory(${PROJECT_SOURCE_DIR}/USP/control SOURCES)
message(STATUS "mainCmake:${SOURCES}")
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^添加源文件SRC^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #

# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>添加头文件INC<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/USP/usb_com)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/USP/control)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^添加头文件INC^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #

# Link with the Webots controller library.
link_directories($ENV{WEBOTS_HOME}/lib/controller)
set (LIBRARIES ${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_LIBRARY_PREFIX}CppController${CMAKE_SHARED_LIBRARY_SUFFIX})
include_directories(
$ENV{WEBOTS_HOME}/include/controller/c 
$ENV{WEBOTS_HOME}/include/controller/cpp)

# Setup the target executable.
add_executable(${PROJECT} ${SOURCES})
target_link_libraries(${PROJECT} ${LIBRARIES})
